﻿

Imports System.IO


Public Class DbfsMemoryStream
    Inherits MemoryStream


    Private _method As Action(Of Byte())

    Public Sub New(ByVal method As Action(Of Byte()))
        MyBase.New()
        _method = method
    End Sub


    Public Sub New(ByVal buffer As Byte(), ByVal method As Action(Of Byte()))
        MyBase.New(buffer)
        _method = method
    End Sub

    Public Sub New(ByVal buffer As Byte(), _
                   ByVal index As Integer, _
                   ByVal count As Integer, _
                   ByVal writable As Boolean, _
                   ByVal publiclyVisible As Boolean, _
                   ByVal method As Action(Of Byte()) _
                   )
        MyBase.New(buffer, index, count, writable, publiclyVisible)
        _method = method
    End Sub

    Public Overrides Sub Flush()
        MyBase.Flush()
        _method(GetBuffer())
    End Sub
End Class
